package com.dwxt.parabolic.controller;

import com.dwxt.common.base.BaseResult;
import com.dwxt.parabolic.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@RequestMapping("/parabolic/file")
@RestController
public class FileController {

    @Autowired
    private FileService fileService;

    @RequestMapping("/saveFileLocal")
    public BaseResult saveFileLocal(MultipartFile file) throws IOException {
        String fileUrl = fileService.saveFile(file, null);
        return BaseResult.ok(fileUrl);
    }

    @RequestMapping("/saveEventFile")
    public BaseResult saveEventFile(MultipartFile[] file) throws IOException {
        List<String> list = fileService.saveEventFile(file);
        return BaseResult.ok(list);
    }

}
